#include "Object.h"
#include "../Graphic/GraphicManager.h"
#include <math.h>

//Render method
void cObject::Render()
{
  cGraphicManager::Get().SetColor(eLightYellow, eBlack);
  cGraphicManager::Get().WriteChar(muiX, muiY, mcSymbol);
}

//Get orientation from a point
eOrientation cObject::GetOrientation(unsigned luiX, unsigned luiY)
{
  if ((luiX == muiX) && (luiY == muiY))  return eO_Over;
  if ((luiX == muiX) && (luiY < muiY))   return eO_North;
  if ((luiX > muiX)  && (luiY < muiY))   return eO_NorthEast;
  if ((luiX > muiX)  && (luiY == muiY))  return eO_East;
  if ((luiX > muiX)  && (luiY > muiY))   return eO_SouthEast;
  if ((luiX == muiX) && (luiY > muiY))   return eO_South;
  if ((luiX < muiX)  && (luiY > muiY))   return eO_SouthWest;
  if ((luiX < muiX)  && (luiY == muiY))  return eO_West;
  if ((luiX < muiX)  && (luiY < muiY))   return eO_NorthWest;
}

//Get the distance from the object to a point
float cObject::GetDistance(unsigned luiX, unsigned luiY)
{
  unsigned luiDistanceX = abs((int)(luiX - muiX));
  unsigned luiDistanceY = abs((int)(luiY - muiY));
  return sqrt((float)(luiDistanceX * luiDistanceX +
    luiDistanceY * luiDistanceY));
}
